import { permissionRoutes } from "../router/index";

// 是否有权限

function hasPermission(routeList,roles) {
    let newList = routeList.filter(elememt=>{
        let { children,meta } = elememt;
        if (children && children[0]) {
            elememt.children =  hasPermission(children,roles)
        }
        if (meta) {
            let curPer = meta.permission;
            if (roles.includes(curPer)) {
                return true;
            }
        }
        return false;
    });
    return newList;
    //console.log(newList);
}

// 权限验证
function filterAsyncRouter(roesList) {
    return permissionRoutes;
    let roles = roesList;
    return hasPermission(permissionRoutes,roles);
}
export default filterAsyncRouter;